#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=3e4+10;
int lena,loc[MAXN],sum,ans;
char a[MAXN];
int main()
{
	scanf("%s",a);lena=strlen(a);
	for(int i=0;i<lena;++i)
		if(a[i]=='a'&&a[i+1]=='g'&&a[i+2]=='n'&&a[i+3]=='u'&&a[i+4]=='s')
		{
			loc[++sum]=i;
			i+=4;
		}
	int j=1;
	for(int i=0;i<lena;++i)
	{
		if(i<=loc[j])ans+=lena-loc[j]-4;
		if(i==loc[j])++j;
	}
	printf("%d\n",ans);
	return 0;
}
